package com.lxy.servlet;

import com.lxy.dao.StudentDao;
import com.lxy.dao.student;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class StuServlet extends HttpServlet{



        public void doPost(HttpServletRequest request , HttpServletResponse response) throws ServletException, IOException {
                student s = new student();
                s.setAge(request.getParameter("age"));
                s.setCardnumber(request.getParameter("cardnumber"));
                s.setCollege(request.getParameter("college"));
                s.setCurriculum(request.getParameter("curriculum"));
                s.setGrade(request.getParameter("grade"));
                s.setName(request.getParameter("name"));
                s.setNumber(request.getParameter("number"));
                StudentDao studentDao = new StudentDao();
                studentDao.insert_s(s);
            response.sendRedirect("manager.jsp");
        }


        public void doGet(HttpServletRequest req,HttpServletResponse rep) throws IOException, ServletException {

            StudentDao studentDao = new StudentDao();
            List<student> list = studentDao.select();
          req.setAttribute("list",list);
     req.getRequestDispatcher("manager.jsp").forward(req,rep);
        }


}
